﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;

namespace UserPower.Models
{
    public class MyDbContext : DbContext
    {
        // You can add custom code to this file. Changes will not be overwritten.
        // 
        // If you want Entity Framework to drop and regenerate your database
        // automatically whenever you change your model schema, please use data migrations.
        // For more information refer to the documentation:
        // http://msdn.microsoft.com/en-us/data/jj591621.aspx
    
        public MyDbContext() : base("name=MyDbContext")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); //禁止级联删除 
        }

        public System.Data.Entity.DbSet<UserPower.Models.SysRole> SysRoles { get; set; }

        public System.Data.Entity.DbSet<UserPower.Models.SysUser> SysUsers { get; set; }

        public System.Data.Entity.DbSet<UserPower.Models.SysDepartment> SysDepartments { get; set; }

        public System.Data.Entity.DbSet<UserPower.Models.SysUserRole> SysUserRoles { get; set; }

        public System.Data.Entity.DbSet<UserPower.Models.Student> Students { get; set; }

        
    }
}
